﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NetPE.Dialogs
{
    public partial class FindDialog : Form
    {
        public FindDialog()
        {
            InitializeComponent();
        }

        public event EventHandler<FindEventArgs> Find;

        private void button1_Click(object sender, EventArgs e)
        {
            byte[] b = Encoding.ASCII.GetBytes(textBox1.Text);
            if (Find != null)
            {
                Find(this, new FindEventArgs(b));
                this.Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            byte[] b = new byte[textBox2.Text.Length / 2];
            for (int i = 0; i < textBox2.Text.Length / 2; i++)
            {
                b[i] = byte.Parse(textBox2.Text.Substring(i * 2, 2));
            }
            if (Find != null)
            {
                Find(this, new FindEventArgs(b));
                this.Close();
            }
        }
    }

    public class FindEventArgs : EventArgs
    {
        public FindEventArgs(byte[] val) { this.val = val; }
        byte[] val;
        public byte[] Value { get { return val; } }
    }
}
